package com.wanfan.wanfanBrush.design.countingPolicy;

import com.wanfan.wanfanBrush.exception.BusinessException;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * 反爬虫检测策略上下文类
 */
@Service
public class AntiCrawlerContext {

    private AntiCrawlerStrategy strategy;

    public AntiCrawlerContext(@Qualifier("redisAntiCrawlerStrategy") AntiCrawlerStrategy strategy) {
        this.strategy = strategy;
    }

    /**
     * 执行反爬虫检测
     * @param loginUserId 当前登录用户的 ID
     * @throws BusinessException 业务异常
     */
    public void executeDetect(long loginUserId) throws BusinessException {
        strategy.detect(loginUserId);
    }
}